package HomeWork;

import java.util.Comparator;
import java.util.TreeSet;

public class test2 {
    public static void main(String[] args) {
        TreeSet<Employee> set = new TreeSet<>(new Comparator<Employee>() {
            @Override
            public int compare(Employee o1, Employee o2) {
                int rulue = o2.getSalary() - o1.getSalary();
                rulue = rulue==0 ? o1.getAge()-o2.getSalary():rulue;
                rulue = rulue==0 ? o1.getName().compareTo(o2.getName()):rulue;
                return rulue;
            }
        });

        Employee e1 = new Employee("lu陆地",19,3000);
        Employee e2 = new Employee("caicaini菜菜你",21,3001);
        Employee e3 = new Employee("maomao猫猫风",22,3002);
        Employee e4 = new Employee("aa啊啊搏",30,3003);
        Employee e5 = new Employee("caicaifeng采采风",21,3001);
        set.add(e1);
        set.add(e2);
        set.add(e3);
        set.add(e4);
        set.add(e5);
        System.out.println(set);
    }
}
class Employee{
    private String name;
    private int age;
    private int salary;

    public Employee() {
    }

    public Employee(String name, int age, int salary) {
        this.name = name;
        this.age = age;
        this.salary = salary;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public int getSalary() {
        return salary;
    }

    public void setSalary(int salary) {
        this.salary = salary;
    }

    @Override
    public String toString() {
        return "Employee{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", salary=" + salary +
                '}';
    }
}
